package controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import entity.HomeNews;
import entity.User;
import net.sf.json.JSONObject;
import service.HomeNewsService;
import service.UserService;
import util.ResponseUtil;
import util.ResultFormatUtil;

@Controller
@RequestMapping("/homeNews")
public class HomeNewsController {
	@Resource
	private HomeNewsService homeNewsService;
	//http://localhost:8080/CampusApp/homeNews/getHomeNewData.do
	@RequestMapping("/getHomeNewData")
	public void getHomeNewData(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List<HomeNews> allHomeNews = homeNewsService.getAllHomeNews();
		if (allHomeNews!=null) {
			JSONObject result = ResultFormatUtil.getResultFrom(true, "HomeNews集合获取成功", allHomeNews);
			ResponseUtil.write(response, result);
		}else{
			JSONObject result = ResultFormatUtil.getResultFrom(false, "HomeNews集合获取失败", allHomeNews);
			ResponseUtil.write(response, result);
		}
		

	}

		//http://192.168.16.140:8080/CampusApp/user/adduser.do
	
	
	
}
